#include <iostream>
#include <memory>
#include "krpc/netserver.h"
#include "krpc/service.h"

std::string echo(std::string content)
{
	std::cout << "recv size is " << content.size() << std::endl;
	return std::move(content);
}

void test_streamserver()
{
	using namespace KRPC;
	LSS server("unix");
	Service service(server);
	service.bind("echo", &echo);
	service.run();
}

void test_dgramserver()
{
	using namespace KRPC;
	LDS server("unix");
	Service service(server);
	service.bind("echo", &echo);
	service.run();
}

int main(int argc, char const *argv[])
{
	if (argc == 2) {	//如果有一个参数则测试unix dgram server
		test_dgramserver();
	} else {	//否则测试unix stream server
		test_streamserver();
	}
	return 0;
}
